package com.earnings.okhttputils.utils.viewbinding;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.earnings.R;
import com.earnings.okhttputils.utils.OkHttp.utils.Yconstant;
import com.earnings.okhttputils.utils.bean.EarningsData;
import com.earnings.okhttputils.utils.ui.dialog.PowerDialog;


/**
 * Created by Administrator on 2017/5/9 0009.
 */

public class EarningsViewBinding extends ViewBinding implements View.OnClickListener {
    public View caibao_view, shangbao_view, earnings_view, consumptiondetail_view, love_view;
    public TextView subsidy_tv, zrsubsidy_tv, my_love_tv, power_tv, money_tv;
    public ImageView imageView2, yuan_img;
    public Button more_bt;
    //public Banner banner_view;
    public PowerDialog powerDialog;
    private setOnClickListener onClickListener;
    private View OnClickViews[];


    public EarningsViewBinding(View mView) {
        super(mView);;
    }

    @Override
    public void initBindingView() {
        earnings_view = mView.findViewById(R.id.earnings_view);
        love_view = mView.findViewById(R.id.love_view);
        consumptiondetail_view = mView.findViewById(R.id.consumptiondetail_view);
        subsidy_tv = (TextView) mView.findViewById(R.id.subsidy_tv);
        zrsubsidy_tv = (TextView) mView.findViewById(R.id.zrsubsidy_tv);
        my_love_tv = (TextView) mView.findViewById(R.id.my_love_tv);
        power_tv = (TextView) mView.findViewById(R.id.power_tv);
        money_tv = (TextView) mView.findViewById(R.id.money_tv);
        more_bt = (Button) mView.findViewById(R.id.more_bt);
       // banner_view = (Banner) mView.findViewById(R.id.banner_view);
        imageView2 = (ImageView) mView.findViewById(R.id.imageView2);
        yuan_img = (ImageView) mView.findViewById(R.id.yuan_img);
      //  banner_view.setOnBannerListener(this);
        powerDialog=new PowerDialog(mContext);
        my_love_tv.setOnClickListener(this);
        love_view.setOnClickListener(this);
        earnings_view.setOnClickListener(this);
        power_tv.setOnClickListener(this);
        consumptiondetail_view.setOnClickListener(this);
        more_bt.setOnClickListener(this);
        OnClickViews = new View[]{my_love_tv, love_view, earnings_view, power_tv, consumptiondetail_view};
    }

    public void setViewClick(boolean click) {
        for (int i = 0; i < OnClickViews.length; i++) {
            OnClickViews[i].setClickable(click);
        }
    }


    public void setOnClickListener(setOnClickListener onClickListener) {
        this.onClickListener = onClickListener;

    }


    //设置数据
    public void setViewData(EarningsData earningsData) {
        //累计补贴
        subsidy_tv.setText(earningsData.getRichget());
        //昨日补贴
        zrsubsidy_tv.setText(earningsData.getYesterday_rich());
        //个人爱心值
        my_love_tv.setText("个人爱心数：" + earningsData.getLove());
        //个人动力值
        power_tv.setText("个人动力数：" + earningsData.getPower());
        //带补贴财币richstay
        money_tv.setText(earningsData.getRichstay());

    }

    //切换皮肤
    public void greycrystal(int type) {
        switch (type) {
            //百世商城
            case Yconstant.TYPE_BSSC:
                earnings_view.setBackgroundResource(R.color.top_rad);
                imageView2.setImageResource(R.mipmap.bs_yanjing);
                yuan_img.setImageResource(R.mipmap.bs_yuan);

                //招财汇宝
                break;
            case Yconstant.TYPE_ZCHB:
                earnings_view.setBackgroundResource(R.color.top_blue);


                break;
            default:
                break;
        }
    }

    @Override
    public void onClick(View view) {
        if (view == my_love_tv) {
            onClickListener.My_love(my_love_tv);
        }
        if (view == consumptiondetail_view) {
            this.onClickListener.Consumptiondetail(consumptiondetail_view);
        }
        if (view == love_view) {
            this.onClickListener.Love_tv(love_view);
        }
        if (view == earnings_view) {
            this.onClickListener.Earnings(earnings_view);
        }
        if (view == power_tv) {
            this.onClickListener.ShowPowerDialog(power_tv, powerDialog);
        }
        if (view == more_bt) {
            this.onClickListener.Zc_More(more_bt);
        }

    }




    public interface setOnClickListener {
        //个人动力
        void ShowPowerDialog(View view, PowerDialog powerDialog);

        //详情
        void Earnings(View view);

        //消费明细
        void Consumptiondetail(View view);

        //我的爱心
        void My_love(View view);

        //爱心明细
        void Love_tv(View view);

        //招财补贴
        void Zc_More(View view);

        //广告轮播
        void Banner(View view, int position);
    }


}
